package com.purchase.ml.mapper.order;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.purchase.ml.entity.order.SysOrder;
import com.purchase.ml.entity.order.SysOrderDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @description: 订单
 * @author kyyang
 * @date 2021/2/28 19:55
 * @version 1.0
 */
@Mapper
@Repository
public interface SysOrderDetailMapper extends BaseMapper<SysOrderDetail> {

    /**
     * 通过订单号查询出该订单的订单详情
     * @param oid
     * @return
     */
    @Select("select * from sys_order_detail where oid=#{oid}")
    List<SysOrderDetail> findDetailByOid(@Param("oid") Long oid);

    /**
     * 链接组合查询 daizh
    * */
//    @Select("select \n" +
//            "t1.oid,t1.product_id,t1.quantity,t1.allmoney,t1.allmoney,t1.price,t1.buyunit,t3.pic_url,t2.product_name\n" +
//            "from sys_order_detail t1\n" +
//            "left join (select product_id,product_name from sys_product )t2 on t1.product_id = t2.product_id\n" +
//            "left join (select product_id,pic_url,`index` from sys_product_pic ) t3 on t1.product_id = t3.product_id \n" +
//            "where oid = #{oid}\n" +
//            "ORDER BY t3.`index` asc LIMIT 1")
    List<SysOrderDetail> findDetailAndProductInfoByOid(@Param("oid") Long oid);
}
